<%@page contentType="text/html; charset=utf-8"%>
<%@ include file="../inc/TagLibs.jsp"%>
<c:if test="${type=='BUY'}">
	<c:set var="billTypeName" value="采购" />
</c:if>
<c:if test="${type=='BACK'}">
	<c:set var="billTypeName" value="退货" />
</c:if>
<c:set var="pageTitle" value="${billTypeName}单审核" />
<%@ include file="../inc/Title.jsp"%>
<head>
<link rel="stylesheet" type="text/css" href="/css/base.css" />
<link href="/css/Query.css" rel="stylesheet" type="text/css">
<script src="/js/QueryList.js"></script>
<script src="/js/popup_ext.js"></script>
<script language="javascript">
	function doShow(id){
		var url="/purchase/PurchaseBillInfoForExamine.ihtm?id="+id;
		ShowIframe("${billTypeName}单审核",url,900,500,"refreshWin()",900,600);
	}
	function refreshWin(){
		if(popRetVal!=null){
			window.location=window.location;
		}
	}
	function doExamineCallBack(id){
		if(popRetVal!=null){
			var url="/purchase/PurchaseBillExamine.ihtm?id_str="+id+"&flag=1";
			ShowIframe("${billTypeName}单审核",url,200,200,"refreshWin()");
		}
	}
	function doExamine(id){
		ShowConfirm('确认框','确定审核通过吗？',340,80,"doExamineCallBack('"+id+"')");
	}
	function doMutiExamine(){
		var ob_arr = document.getElementsByName("query_checkbox");
		var str="";
		for (i=0;i<ob_arr.length;i++){
			if ((ob_arr[i].checked == true)){
				if(str!=""){
					str=str+";";
				}
				str = str+ob_arr[i].value;
			}
		}
		if(str!=""){
			doExamine(str);
		}else{
			ShowAlert('提示框','请选择要审核的单据',200,100);
		}
	}
	function doSearch(){
		var searchKey=encodeURIComponent(document.getElementById("search_key").value.trim());
		var tsId=document.getElementById("ts_id").value;
		window.location="/purchase/PurchaseBillListForExamine.ihtm?ts_id="+tsId+"&type=${type}&search_key="+searchKey;
	}
	function doGo(pageIndex){
		var searchKey=encodeURIComponent("${searchKey}");
		window.location="/purchase/PurchaseBillListForExamine.ihtm?ts_id=${tsId}&type=${type}&search_key="+searchKey+"&current_page="+pageIndex;
	}
	function doJump(pageIndex){
		if(window.event.keyCode==13){
			doGo(pageIndex);
		}
	}
	function DoubleClick(it){
		var ob_arr = document.getElementsByName("query_checkbox");
		var str="";
		if(ob_arr.length>=it.getAttribute("index")){
			str=ob_arr[it.getAttribute("index")-1].value;
		}
		if(str==""){
			return;
		}
		doShow(str);
	}
	function doCancel(){
		window.close();
	}
	function doInit(){
		//Window_Onload();
		document.getElementById("search_key").focus();
	}
	function checkSearchKey(){
		if(window.event.keyCode==13){
			doSearch();
		}
	}
</script>
</head>
<body oncontextmenu="return false" onLoad="doInit();" class="sheet" style="text-align:center">
<div class="sheet-main" style="width:860px;text-align:left;margin:auto;">
  <div class="sheet-top">
    <div class="content">
      <h2>${billTypeName}单审核</h2>
      <p>在这里可以对所有未审核的${billTypeName}单进行审核操作</p>
    </div>
  </div>
  <div class="sheet-list">
    <div class="search-business">
      <div class="content">
        <table width="100%">
          <tbody>
            <tr>
              <td >
              <div align="right">
					<input type="text" class="TextBox" id="search_key" name="search_key" onKeyUp="checkSearchKey();" value="${searchKey}"  title="以供应商名称、供应商拼音字头、摘要、${billTypeName}单号进行模糊查询">
					<select name='ts_id' id="ts_id">
						<option value="0">==请选择账套==</option>
						<c:forEach var="item" items="${tsList}">
						<option value="${item.id}" <c:if test="${tsId==item.id}">selected</c:if>>${item.title}</option>
						</c:forEach>
			  		</select>
					<input type="button"  value=" 查 询" onClick="doSearch();"  class="buttom search-but"  title="以供应商名称、供应商拼音字头、摘要、${billTypeName}单号进行模糊查询"> 
					<input type="button" class="buttom  search-audit" value=" 审核通过" onClick="doMutiExamine();">       
			   </div>
				</td>
            </tr>    
            </tbody>      
        </table>      	 
      </div>
	  <%@include file="../inc/AlertMsg.jsp"%>
	  <div class="table-list">
        <table width="100%">
          <tr>   
						<th width="14"><input type="checkbox" onClick="javascript:checkall(this);"></th>
						<th width="14%">单号</th>
						<th width="10%">${billTypeName}日期</th>
						<th width="24%">供应商</th>
						<th width="10%">金额</th>
						<th width="10%">预付</th>
						<th width="10%">经办人</th>
						<th width="10%">仓库名称</th>
						<th width="12%">操作</th>
					</tr>
					<c:forEach var="item" items="${qr.list}" varStatus="i">
						<c:if test="${(i.index mod 2)==0}"><c:set var="trClass" value="query_list_data_tr1" /></c:if>
						<c:if test="${(i.index mod 2)!=0}"><c:set var="trClass" value="query_list_data_tr2" /></c:if>
						<tr class="${trClass}" index="${i.index+1}" style='cursor:pointer;' ondblclick='javascript:DoubleClick(this)' onClick='javascript:ClickCheck(this,true)' onmouseout='javascript:mouseout(this)' onmouseover='javascript:mouseover(this)'>
							<td><input type="checkbox" onClick="javascript:ClickCheck(this,true);" name='query_checkbox' value="${item.purchaseBill.id}"></td>
							<td>${item.purchaseBill.billCode}</td>
							<td><fmt:formatDate value="${item.purchaseBill.purchaseDate}" pattern="yyyy-MM-dd"/></td>
							<td>${item.providerName}</td>
							<td>${item.purchaseBill.cost}</td>
							<td>${item.purchaseBill.imprest}</td>
							<td>${item.purchaseBill.managerName}</td>
							<td><commonTag:showSimpleObjectName list="${storehouseList}" objectId="${item.purchaseBill.storehouseId}" /></td>
							<td>
								<a href="javascript:doExamine('${item.purchaseBill.id}');">审核通过</a>
								<a href="javascript:doShow('${item.purchaseBill.id}');">查看</a>
							</td>
						</tr>
					</c:forEach>
				</table>
			<%@include file="../inc/Pages.jsp"%>
      </div>     
    </div>
  </div>
</div>
</body>
</html>
